<template>
    <div class="contract-list-page ContractReissueList">
        <Card>
            <div class="form">
                <ReissueForm
                    :formValidate="formValidate"
                    @getList="getList"
                    :dataDict="dataDict"
                    @showModal="showModal"
                />

            </div>
            <div class="table">
                <ReissueTable
                    :isSP="isSP"
                    :formValidate="formValidate"
                    :dataDict="dataDict"
                    :contractTable="contractTable"
                    @getList="getList"
                    @showContractDetial="showContractDetial"
                />
            </div>

        </Card>
        <ActivatedCase
            :contractBusiness="contractBusiness"
            :getDataFn="getDataFn"
            :isSP="isSP"
            :modal="modal"
            modalTitle="已激活案件列表"
            :dataDict="dataDict"
            @showContractDetial="showContractDetial"
            @closeModal="closeModal"
        />
<!--        <button @click="showContractDetial({contractNo:'N888888'})">合同重出信息填写页面</button>-->
    </div>
</template>
<script>
    import {mapGetters} from "vuex";
    import {findActivatedContractList} from "_p/basic/api/contract/post-loan-info-change";
    import {findContractReissueList} from "_p/basic/api/contract/contract-reissue/index";

    import {channelType} from "_p/basic/api/contract/channel-type/channel-type";
    import {getDictDataList} from "_p/basic/assets/contract/js/utils";

    import ReissueForm from "./ReissueForm";
    import ReissueTable from "./ReissueTable";
    import ActivatedCase from "_p/basic/pages/contract/common/activated-case/index";

    export default {
        // 合同重出列表
        name: "ContractReissueList",
        components: {ReissueForm, ReissueTable, ActivatedCase},
        props: {},
        data() {
            return {
                pageNo: 1,
                // 放款模式(loanModel) 变更类型  变更主体(PersonRoleType)
                dicttArr: ["loanModel", "PersonRoleType", "contractProcessStu", "contractStatus","channelType","businessSource","channelBelong","contractVersion"],
                dataDict: {},
                modalTitle: "已激活案件列表",
                modal: false,
                contractBusiness: [
                    "assetsChange",
                    "reprintContract",
                ],
                loading: false,
                // 日期区间
                isDateErr: false,
                endTime: "",
                formValidate: {
                    amount: "", //溢缴款
                    applyNo: "", // 申请编号
                    caseNo: "", // 案件编号
                    closeDate: "", // 合同关闭日期
                    contactNo: "", // 联系方式
                    contractNo: "", // 合同号
                    contractStatus: "", // 合同状态
                    applyDate: "", //	string($date-time) // 申请时间
                    custName: "", // 客户姓名
                    endTime: "", //	string($date-time) // 结束时间
                    id: "", // id
                    pageNumber: 1, // integer($int32) // 当前页
                    pageSize: 10, //integer($int32) // 多少条
                    processMode: "", // 处理方式
                    channelFullName: null, //
                    endDate: null, //
                    businessSource: null, //
                    channelType: null, //
                    processStatus: null, //
                    allCase: false,

                },
                ruleInline: {},

                contractTable: {
                    current: 1, // 表格当前页
                    pages: 0,
                    searchCount: false,
                    size: 10,
                    total: 0,
                    orders: [],
                    records: []
                },
                pageSizeOpts: [10, 20, 50, 100],
                // selct 数据字典
                processModeDict: []
            };
        },
        computed: {
            ...mapGetters({userInfo: "userInfo", roleType: "roles"}),
            getDataFn: () => findActivatedContractList,
            // 是否是合作商
            isSP: function () {
                return channelType(this.roleType)
                // return true;
            },
        },
        created() {
        },
        mounted() {
            this.init();

        },
        activated() {
            this.init();
        },
        methods: {
            init() {
                this.getDictDataList();
                this.getList(
                    Object.assign({}, this.formValidate, )
                );
            },
            getDictDataList() {
                getDictDataList(this.dicttArr).then(res => {
                    this.dataDict = res;
                });
            },
            getList(data) {
                findContractReissueList(data).then(res => {
                    this.loading = false;
                    if (res.code === "0000") {
                        this.contractTable = res.data;
                        console.log("res.data",res.data)
                    } else {
                        this.$Message.error("Fail!");
                    }
                });
            },

            // 分页 Fn
            changePageSize(num) {
                this.getList(
                    Object.assign({}, this.formValidate, {pageSize: num})
                );
                this.formValidate.pageSize = num;
            },
            changePage(num) {
                this.getList(
                    Object.assign({}, this.formValidate, {pageNumber: num})
                );
                this.formValidate.pageNumber = num;
            },
            showContractDetial(params) {
                // console.log("showContractDetial(params)", params);
                if (!params && !params.contractNo) return;
                this.modal = false;
                this.afs.newTab(
                    this,
                    "projects/basic/pages/contract/contract-reissue/contract-reissue-detial/index",
                    "合同重出详情",
                    "ios-add",
                    params,
                    "contract-reissue-detial-" + this.pageNo,
                    [],
                    true
                );
                this.pageNo += 1;
            },
            // 弹窗
            showModal() {
                this.modal = true;
            },
            closeModal() {
                this.modal = false;
            }
        }
    };
</script>
<style lang="less">
    @import "../../../../styles/common/form.less";

    .ContractReissueList {
        .table {
            padding-top: 16px;
        }
    }
</style>
